package com.parking.mgr.useraccount.service;

import com.baomidou.mybatisplus.extension.service.IService;
import com.parking.mgr.useraccount.model.entity.BasicAuthCodeEntity;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @ClassName AuthCodeService
 * @Description TODO
 * @Auther: zhijianpu
 * @Date: 2023/6/14
 */
public interface AuthCodeService extends IService<BasicAuthCodeEntity> {

    /**
     * 生成图片验证码
     *
     * @param request 请求对象
     * @param eventCode 事件编码
     * @param clientId 客户端ID
     * @throws IOException 异常
     */
    void identifyImageCode(HttpServletRequest request, HttpServletResponse response, String eventCode, String clientId) throws IOException;

    /**
     * 根据ID获取验证码
     *
     * @param id
     * @return
     */
    String getAuthCodeById(String id);

    /**
     * 通过 clientId 获取验证实体
     *
     * @param clientId 客户端ID
     * @return 验证码
     */
    BasicAuthCodeEntity getAuthCodeEntityByClientId(String clientId);

    /**
     * 验证码失败，更新验证码状态和验证结果
     *
     * @param id
     */
    void updateAuthCodeByAuthFail(String id, String passportId, String clientId);

    /**
     * 验证码成功，更新验证码状态和验证结果，同时迁移到历史表
     *
     */
    void updateAuthCodeByAuthSuccess(String id, String passportId, String clientId, String loginToken);
}
